'\" t
.\"
.\" Copyright (c) 2016-2018 Red Hat.
.\" Copyright (c) 2009 Max Matveev
.\" Copyright (c) 2009 Aconex.  All Rights Reserved.
.\"
.\" This program is free software; you can redistribute it and/or modify it
.\" under the terms of the GNU General Public License as published by the
.\" Free Software Foundation; either version 2 of the License, or (at your
.\" option) any later version.
.\"
.\" This program is distributed in the hope that it will be useful, but
.\" WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
.\" or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
.\" for more details.
.\"
.\"
.TH MMV 5 "" "Performance Co-Pilot"
.SH NAME
\f3mmv\f1 \- Memory Mapped Values for Performance Co-Pilot
.SH SYNOPSIS
.I $PCP_TMP_DIR/mmv/<file>
.SH DESCRIPTION
The files in \f2$PCP_TMP_DIR/mmv\f1 are generated either by the
\f2mmv_stats_init\f1(3) and \f2mmv_stats2_init\f1(3) functions
from the \f3libpcp_mmv\f1 library, or by a native language module
such as Parfait (Java), Speed (Golang) or Hornet (Rust).
.PP
There could be multiple files in this directory, each file representing
a single source of the performance metrics.
The metrics are harvested by
.BR pmdammv (1)
which exports them to the rest of the Performance Co-Pilot infrastructure.
.SH FILE FORMAT
Each file starts with the following header:
.TS
box,center;
c | c | c
n | n | l.
Offset	Length	Name
_
0	4	tag == "MMV\\0"
_
4	4	Version (1 or 2)
_
8	8	Generation 1
_
16	8	Generation 2
_
24	4	Number of TOC entries
_
28	4	Flags
_
32	4	Process identifier (PID)
_
36	4	Cluster identifier
.TE
.PP
The version number specifies which mapping layout format is
in use.
There are two, both are very similar, as described below.
The sole purpose of the MMV version 2 format is to allow the
use of longer metric and instance names.
If names longer than MMV_NAMEMAX are not in use, it is best
to use MMV version 1 format as this allows older versions of
PCP to also consume the data.
Support for v2 format was added in the pcp-3.11.4 release.
.PP
The generation numbers are timestamps at the time of file
creation, and must match for the file to be considered by
the MMV PMDA.
.PP
The flags can specify ways in which the client would like
the MMV PMDA to behave - e.g. the MMV_FLAG_PROCESS flag
specifies that only if the process identified by PID is
currently running should those values be exported.
.PP
Finally, if set, the cluster identifier is a hint to the MMV
PMDA as to what cluster should be used with this application
when forming the individual metric identifiers.
A performance metric identifier (see \f2PMDA\f1(3)) consists of
the PMDA domain number, the cluster number, and the individual
item numbers described in the Metrics section.
.PP
The header is followed by at least 2 TOC sections:
one section for metrics and another for values.
The TOC section has the following format:
.TS
box,center;
c | c | c
n | n | l.
Offset	Length	Value
_
0	4	Section Type (see \f2mmv_stats.h\f1)
_
4	4	Number of entries in the section
_
8	8	Section's offset from the start of the file
.TE
.PP
The section types are:
.IP
1:
Indoms (instance domain definitions)
.IP
2:
Instances
.IP
3:
Metrics (metric definitions)
.IP
4:
Values
.IP
5:
String
.IP
6:
Labels
.PP
The only mandatory sections are Metrics and Values.
Indoms and Instances sections of either version only appear if there are
metrics with multiple instances.
String sections only appear if there are metrics with string values,
when Metrics or Indoms are defined with help text, or in v2 MMV format
where metric names and instance names are stored in string sections
(providing significantly more space than v1 MMV format for these names).
Label sections only appear if there are metrics annotated with labels
(name/value pairs).
Labels are supported in v3 MMV format.
.PP
The entries in the Indoms sections have the following format:
.TS
box,center;
c | c | c
n | n | l.
Offset	Length	Value
_
0	4	Unique serial number for this domain
_
4	4	Number of entries in the domain
_
8	8	Offset to first Instance or Instance2
_
16	8	Short help text offset
_
24	8	Long help text offset
.TE
.PP
The entries in the Instances (v1) section have the following format:
.TS
box,center;
c | c | c
n | n | l.
Offset	Length	Value
_
0	8	Offset into the indom section
_
8	4	Unused padding (zero filled)
_
12	4	Internal instance identifier
_
16	64	External instance identifier
.TE
.PP
The entries in the Instances (v2) section have the following format:
.TS
box,center;
c | c | c
n | n | l.
Offset	Length	Value
_
0	8	Offset into the indom section
_
8	4	Unused padding (zero filled)
_
12	4	Internal instance identifier
_
16	8	External instance identifier string offset
.TE
.PP
The entries in the Metrics (v1) section have the following format:
.TS
box,center;
c | c | c
n | n | l.
Offset	Length	Value
_
0	64	Metric Name
_
64	4	Metric Item (see \f2PMDA\f1(3))
_
68	4	Metric Type (see \f2mmv_stats.h\f1)
_
72	4	Semantics (see \f2PMAPI\f1(3))
_
76	4	Dimensions (see \f2PMAPI\f1(3))
_
80	4	Instance Domain ID
_
84	4	Unused padding (zero filled)
_
88	8	Short help text offset
_
96	8	Long help text offset
.TE
.PP
The entries in the Metrics (v2) section have the following format:
.TS
box,center;
c | c | c
n | n | l.
Offset	Length	Value
_
0	8	Metric Name string offset
_
8	4	Metric Item (see \f2PMDA\f1(3))
_
12	4	Metric Type (see \f2mmv_stats.h\f1)
_
16	4	Semantics (see \f2PMAPI\f1(3))
_
20	4	Dimensions (see \f2PMAPI\f1(3))
_
24	4	Instance Domain ID
_
28	4	Unused padding (zero filled)
_
32	8	Short help text offset
_
40	8	Long help text offset
.TE
.PP
The entries in the Values section have the following format:
.TS
box,center;
c | c | c
n | n | l.
Offset	Length	Value
_
0	8	\f3pmAtomValue\f1 (see \f2PMAPI\f1(3))
_
8	8	Extra space for STRING and ELAPSED
_
16	8	Offset into the Metrics section
_
24	8	Offset into the Instances section
.TE
.PP
Each entry in the strings section is a 256 byte character array,
containing a single NULL-terminated character string.
So each string has a maximum length of 256 bytes, which includes
the terminating NULL.
.PP
The entries in the Labels (v3) section have the following format:
.TS
box,center;
c | c | c
n | n | l.
Offset	Length	Value
_
0	4	T{
Flags - PM_LABEL_ CLUSTER, ITEM, INDOM, INSTANCES and OPTIONAL
T}
_
4	4	T{
Identifier for given type (indom, cluster or item)
T}
_
8	4	T{
Internal Instance or PM_IN_NULL
T}
_
12	244	T{
Payload (Name and Value JSONB String)
T}
.TE
.PP
Each entry in the payload is a 244 byte (maximum) character array,
containing a single NULL-terminated \fIname\fR:\fIvalue\fR pair in
JSON format.
Insignificant whitespace must not be present.
Label names consist only of alphanumeric characters or underscores,
and must begin with an alphabetic.
Upper and lower case characters are considered distinct.
.SH SEE ALSO
.BR PCPIntro (1),
.BR pmdammv (1),
.BR PMAPI (3),
.BR PMDA (3),
.BR mmv_stats_registry (3),
.BR pcp.conf (5)
and
.BR pcp.env (5).

.\" control lines for scripts/man-spell
.\" +ok+ MMV_FLAG_PROCESS MMV_NAMEMAX
.\" +ok+ PM_LABEL_ {from PM_LABEL_[CLUSTER|ITEM|...]}
.\" +ok+ Indoms Golang INDOM _init {from mmv_stats2_init}
.\" +ok+ TOC
